package com.add;

import com.lineage.config.ConfigOther;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.thread.GeneralThreadPool;
import com.lineage.server.world.World;
import java.util.Iterator;

public class L1DayPresentTimer {
  private static MessageTimer _messageTimer;
  
  public static void initialize() {
    _messageTimer = new MessageTimer();
    GeneralThreadPool.get().execute(_messageTimer);
  }
  
  private static void ShowMessageToAll() {
    Iterator<L1PcInstance> iterator = World.get().getAllPlayers().iterator();
    while (iterator.hasNext()) {
      L1PcInstance pc = iterator.next();
      L1DayPresent.forTimeMessage(pc);
    } 
  }
  
  private static class MessageTimer implements Runnable {
    private MessageTimer() {}
    
    public void run() {
      int time = ConfigOther.onlydaytime;
      while (true) {
        try {
          Thread.sleep(time);
        } catch (Exception exception) {
          return;
        } 
        L1DayPresentTimer.ShowMessageToAll();
      } 
    }
  }
}
